import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    userInfo: {},

  },
  getters: {
    isLogin(state) {
      // 最好直接返回布尔值 而不是数字
      // Object.keys(obj) => 数组 [key1,key2,key3]
      return !!Object.keys(state.userInfo).length
    }
  },
  mutations: {
    changeUserInfo(state, data) {
      state.userInfo = data
    }
  },
  actions: {},
  modules: {},
});
